def bucketSort(n):
    Max=max(n)  #不管数有多大,全部兼容
    bucket=[0]*(Max+1)
    for i in n:  #把数装进"桶"里
        bucket[i]+=1
    ans=[]
    for j in range(len(bucket)): #统计
        if bucket[j]!=0:
            for y in range(bucket[j]):
                ans.append(j)
    return ans

n=[1,4,3,2,5,3,6,3,9,4,8,7]
print(bucketSort(n))